import { request } from '@/service'

interface ResultType {
  result: {
    resultCode: string
    resultMessage: string
  }
  data: object
}

/** 适配接口返回结果 */
function adapter(obj: ResultType) {
  if (obj.result?.resultCode === '000000') {
    return obj.data
  }
  throw new Error('错误')
}

/** 综合能效水平分析 start */
//查询各企业综合能效列表
export const queryYqDwCzInfo = (params?: any) =>
  request.get('/nxzbpz-qy/queryYqDwCzInfo', { params }).then((res: any) => adapter(res))

export const queryNxzbpzQyInfoList = (params?: any) =>
  request.get('/nxzbpz-qy/queryNxzbpzQyInfoList', { params }).then((res: any) => adapter(res))
//根据id查询企业能效指标配置表
export const queryNxzbpzQyInfo = (params?: any) =>
  request.get('/nxzbpz-qy/queryNxzbpzQyInfo', { params }).then((res: any) => adapter(res))
/** 综合能效水平分析 end */

/** 节能项目管理 start */
//查询节能项目信息列表
export const queryJnXmInfoList = (params?: any) =>
  request.get('/ynxmxx/queryJnXmInfoList', { params }).then((res: any) => adapter(res))

//根据项目id查询用能项目信息
export const queryYnxmxxInfo = (params?: any) =>
  request.get('/ynxmxx/queryYnxmxxInfo', { params }).then((res: any) => adapter(res))
/** 节能项目管理 end */

/** 能耗趋势分析 start */
export const queryYqDwCzInfoList = (params?: any) =>
  request.get('/nxzbpz-qy/queryYqDwCzInfoList', { params }).then((res: any) => adapter(res))
/** 能耗趋势分析 end */
